```python
# Import necessary libraries
import random
from flask import Flask, render_template, request, jsonify
# Create a Flask app
app = Flask(__name__)
# List of characters for generating CAPTCHA code
CAPTCHA_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
# Generate a random CAPTCHA code
captcha_code = ''.join(random.choices(CAPTCHA_CHARS, k=6))
return captcha_code
# Route to render the CAPTCHA page
@app.route('/')
captcha_code = generate_captcha()
return render_template('captcha.html', captcha_code=captcha_code)
# Route to check if the CAPTCHA code entered by the user is correct
@app.route('/check_captcha', methods=['POST'])
user_input = request.form['user_input']
actual_captcha = request.form['captcha_code']
return jsonify(response)
# Run the Flask app
app.run(debug=True)
```
```html
Please enter the following CAPTCHA code:
{{ captcha_code }}
```
This example sets up a simple web application using Flask to generate a random CAPTCHA code and display it to the user. The user is then prompted to enter the CAPTCHA code in a form. When the user submits the form, the server checks if the entered code matches the actual CAPTCHA code, and a corresponding message is displayed. Note that this is a basic example, and in real-world scenarios, CAPTCHAs may be more complex and involve additional security measures to prevent automated attacks.